package GameModel;

import java.util.ArrayList;
import java.util.Date;

import org.simpleframework.xml.Element;

import Player.mPlayer;
/**
 * 
 * @author David Zimmerli
 *
 */
public class mGameStat {

	@Element
	private mPlayer Player;
	// @ElementList
	ArrayList<mCard> HandCards;
	// @ElementList
	ArrayList<mCard> JokerCards;
	int PlayerPoints;
	int FinishRanking;
	private long LastGameReaction;
	String Bet="no_bet";



	/**
	 * Erzeugt pro Spieler ein Kartdeck und sein Punktestandkonto
	 * 
	 * @param userName
	 * @CallFrom mGame
	 */
	public mGameStat(@Element(name = "Player")mPlayer Player) {
		this.Player = Player;
		this.HandCards = HandCards;
		this.JokerCards = JokerCards;
		this.PlayerPoints = 0;
		this.Bet = Bet;
		Date Date = new Date();
		this.FinishRanking = 0;
		this.LastGameReaction = Date.getTime();

	}

	public void setBet(String Bet) {
		if (Bet.equals("little_bet") || Bet.equals("big_bet")) {
		this.Bet = Bet;
		} else {
			this.Bet="no_bet";
		}
	}

	public String getBet() {
		return this.Bet;
	}

	public mPlayer getHandCardsHolder() {
		return this.Player;

	}

	int getFinishRanking() {
		return this.FinishRanking;
	}

	void updateLastGameReaction() {
		Date Date = new Date();
		this.LastGameReaction = Date.getTime();
	}

	long getLastGameReaction() {
		return this.LastGameReaction;

	}


	public int getGamePoints() {
		return this.PlayerPoints;
	}

	public void updatePlayerPoints(int Points) {
		this.PlayerPoints = (this.PlayerPoints +Points);
	}


	public void setJokerCards(ArrayList<mCard> JokerCards) {
		this.JokerCards = JokerCards;
	}

	public ArrayList<mCard> getJokerCards() {
		return JokerCards;
	}


	public void setPlayerCards(ArrayList<mCard> HandCards) {
		this.HandCards = HandCards;

	}


	public ArrayList<mCard> getPlayerCards() {
		return HandCards;
	}

	public mPlayer getPlayer() {
		return this.Player;
	}
	
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((Player == null) ? 0 : Player.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		mGameStat other = (mGameStat) obj;
		if (Player == null) {
			if (other.Player != null)
				return false;
		} else if (!Player.equals(other.Player))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "mGameStat ["
				+ (Player != null ? "Player=" + Player + ", " : "")
				+ (HandCards != null ? "HandCards=" + HandCards + ", " : "")
				+ (JokerCards != null ? "JokerCards=" + JokerCards + ", " : "")
				+ "PlayerPoints=" + PlayerPoints + ", FinishRanking="
				+ FinishRanking + ", LastGameReaction=" + LastGameReaction
				+ ", Bet=" + Bet + "]";
	}

	public void setGamePoints(int points) {
		this.PlayerPoints=points;
	}

}
